package com.createidea.cms.struts.action;

import java.io.File;
import java.util.List;

import com.createidea.cms.service.picture.PictureService;
import com.createidea.cms.to.PictureTo;

public class PictureAction extends BaseAction {
    private String ownerId;
    private PictureService pictureService;
    private List<PictureTo> pictures;
    private PictureTo picture;
    private File image;
	private String fileName;
    private String imageContentType;
	private String imageFileName;
	private String pictureId;
	private String caller; //product ; enterprise
	
    public String loadPictures(){
    	pictures=pictureService.getPicturesForObject(ownerId);
    	return SUCCESS;
    }
    
    public String addPicture(){
		return SUCCESS;
	}
	
	public String savePicture(){
		pictureService.savePicture(picture,image,imageContentType,imageFileName,this.getRequest().getRealPath("/"));
		ownerId=picture.getOwnerId();
		return SUCCESS;
	}
	
	public String editPicture(){
		picture=pictureService.getPicture(pictureId);
		return SUCCESS;
	}
	
	public String updatePicture(){
		pictureService.updatePicture(picture,image,imageContentType,imageFileName,this.getRequest().getRealPath("/"));
		return SUCCESS;
	}
	
	public String deletePicture() {
		picture=pictureService.getPicture(pictureId);
		pictureService.deletePicture(pictureId);
		return SUCCESS;
	}
	
	public String getOwnerId() {
		return ownerId;
	}
	public void setOwnerId(String ownerId) {
		this.ownerId = ownerId;
	}
	public PictureService getPictureService() {
		return pictureService;
	}
	public void setPictureService(PictureService pictureService) {
		this.pictureService = pictureService;
	}
	public List<PictureTo> getPictures() {
		return pictures;
	}
	public void setPictures(List<PictureTo> pictures) {
		this.pictures = pictures;
	}
	public PictureTo getPicture() {
		return picture;
	}
	public void setPicture(PictureTo picture) {
		this.picture = picture;
	}

	public File getImage() {
		return image;
	}

	public void setImage(File image) {
		this.image = image;
	}

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getImageContentType() {
		return imageContentType;
	}

	public void setImageContentType(String imageContentType) {
		this.imageContentType = imageContentType;
	}

	public String getImageFileName() {
		return imageFileName;
	}

	public void setImageFileName(String imageFileName) {
		this.imageFileName = imageFileName;
	}

	public String getPictureId() {
		return pictureId;
	}

	public void setPictureId(String pictureId) {
		this.pictureId = pictureId;
	}

	public String getCaller() {
		return caller;
	}

	public void setCaller(String caller) {
		this.caller = caller;
	}
    
    
}
